#include "TestCheckUserAuth.h"
#include "CardBussiness.h"
#include "common.h"

CPPUNIT_TEST_SUITE_REGISTRATION(TestCheckUserAuth);

TestCheckUserAuth::TestCheckUserAuth(void)
{
}

TestCheckUserAuth::~TestCheckUserAuth(void)
{
}

void TestCheckUserAuth::TestCheckUserAuth_Input_PINCardIs123456_PINInputIs123_ReturnINVALID_PIN()
{
    char sPINInput[] = "123";
    char sPINCard[] = "123456";
    CCardBussiness objCardB;
    CPPUNIT_ASSERT_EQUAL(g_nCount, 3);
    bool bActualResult = objCardB.CheckUserAuth(sPINInput, sPINCard);
    bool bExpectedResult = INVALID_PIN;
    CPPUNIT_ASSERT_EQUAL(bActualResult, bExpectedResult);
    CPPUNIT_ASSERT_EQUAL(g_nCount, 2);
}

void TestCheckUserAuth::TestCheckUserAuth_Input_PINCardIs123456_PINInputIs234567_ReturnINVALID_PIN()
{
    char sPINInput[] = "234567";
    char sPINCard[] = "123456";
    CCardBussiness objCardB;
    CPPUNIT_ASSERT_EQUAL(g_nCount, 2);
    bool bActualResult = objCardB.CheckUserAuth(sPINInput, sPINCard);
    bool bExpectedResult = INVALID_PIN;
    CPPUNIT_ASSERT_EQUAL(bActualResult, bExpectedResult);
    CPPUNIT_ASSERT_EQUAL(g_nCount, 1);
}

void TestCheckUserAuth::TestCheckUserAuth_Input_PINCardIs123456_PINInputIs123456_ReturnVALID_PIN()
{
    char sPINInput[] = "123456";
    char sPINCard[] = "123456";
    CCardBussiness objCardB;
    CPPUNIT_ASSERT_EQUAL(g_nCount, 1);
    bool bActualResult = objCardB.CheckUserAuth(sPINInput, sPINCard);
    bool bExpectedResult = VALID_PIN;
    CPPUNIT_ASSERT_EQUAL(bActualResult, bExpectedResult);
    CPPUNIT_ASSERT_EQUAL(g_nCount, 1);
}

void TestCheckUserAuth::TestCheckUserAuth_Input_PINCardIs123456_PINInputIs12345_ReturnINVALID_PIN_LOCK()
{
    char sPINInput[] = "12345";
    char sPINCard[] = "123456";
    CCardBussiness objCardB;
    CPPUNIT_ASSERT_EQUAL(g_nCount, 1);
    bool bActualResult = objCardB.CheckUserAuth(sPINInput, sPINCard);
    bool bExpectedResult = INVALID_PIN_LOCK;
    CPPUNIT_ASSERT_EQUAL(bActualResult, bExpectedResult);
    CPPUNIT_ASSERT_EQUAL(g_nCount, 3);
}